package com.seu.me.test;

import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang3.time.DateFormatUtils;

import java.util.Date;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

/**
 * @author liangfeihu
 * @since 2019/3/29
 */
public class MyTest8 {

    public static void main(String[] args) {
        System.out.println(StringUtils.substringBefore("10.11.23.23:8888:10", ":"));
        System.out.println(StringUtils.substringAfter("10.11.23.23:8888:10", ":"));
        System.out.println(StringUtils.substringAfterLast("10.11.23.23:8888:10", ":"));
        Object value1 = null;
        System.out.println(Boolean.TRUE.equals(value1));
        Object value2 = true;
        System.out.println(Boolean.TRUE.equals(value2));
        Object value3 = Boolean.FALSE;
        System.out.println(Boolean.TRUE.equals(value3));
        Object value4 = Boolean.TRUE;
        System.out.println(Boolean.TRUE.equals(value4));

        ScheduledExecutorService scheduledExecutorService = Executors.newSingleThreadScheduledExecutor();
        scheduledExecutorService.scheduleWithFixedDelay(new HeartBeatTask(), 0, 2, TimeUnit.SECONDS);

    }

    private static class HeartBeatTask implements Runnable {
        @Override
        public void run() {
            System.out.println("定时任务 " + DateFormatUtils.format(new Date(), "yyyy-MM-dd HH:mm:ss"));
        }
    }

}
